﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DBTramite.BussinesEntities;

namespace DBTramite.Repository
{
    public class T_SalidaRepository : MasterRepository, IT_SalidaRepository
    {

        public List<T_Salida> GetSalidaByCriterio(string criterio)
        {
            var query = from s in Context.T_Salida
                        select s;
            if (criterio != null && criterio != "")
            {
                query = from s in query
                        where s.nroexpediente.ToUpper().Contains(criterio.ToUpper()) ||
                              s.nroexpediente.ToUpper().Contains(criterio.ToUpper())
                        select s;
            }
            return query.ToList();
        }

        public T_Salida GetSalidaById(int id)
        {
            return Context.T_Salida.Find(id);
        }

        public void UpdateSalida(T_Salida salida)
        {
            var salidaDB = (from s in Context.T_Salida
                            where s.nroexpediente.Equals(salida.nroexpediente)
                            select s).SingleOrDefault();
        }




        public void AddSalida(T_Salida salida)
        {
            Context.T_Salida.Add(salida);
            Context.SaveChanges();
        }
    }

}
